
const https = require("https");
function checkUpdate(callback, oneror) { 
    // ?w='+Math.random()
    https.get('https://ldc-1251285021.cos.ap-shanghai.myqcloud.com/download/inneride/layame/testUrl.json', (res) => { 
        let { statusCode } = res; 
        let contentType = res.headers["content-type"];
        let error;
        if (statusCode !== 200) { 
            error = new Error(`${statusCode}`);
        } 
        else if (/^text\/html$/.test(contentType)) {
            error = new Error(`${contentType}`);
            
        } 
        if (error && oneror) { 
            oneror(error);
        }
        res.setEncoding("utf8"); 
        let data = "";
        res.on("data", (info) => {
            data += info;
        });
        res.on("end", () => {
            // console.log('--',data);

            try {
                let JsonData = JSON.parse(data);
                callback(JsonData);
            } catch(e) {
                oneror(e);
            }
        });
    })
}

exports.checkLayameTestUrlUpdate = checkUpdate;